package com.example.radiocheck;

import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
import android.app.Activity;

public class MainActivity extends Activity {
	private RadioGroup radioGroup = null;
	private RadioButton femaleButton = null;
	private RadioButton maleButton = null;
	private CheckBox checkSwim = null;
	private CheckBox checkRun = null;
	private CheckBox checkRead = null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        radioGroup = (RadioGroup)findViewById(R.id.myRadioGroup);
        femaleButton = (RadioButton)findViewById(R.id.myRadioButton1);
        maleButton = (RadioButton)findViewById(R.id.myRadioButton2);
        checkSwim = (CheckBox)findViewById(R.id.myCheckSwim);
        checkRun = (CheckBox)findViewById(R.id.myCheckRun);
        checkRead = (CheckBox)findViewById(R.id.myCheckRead);
        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
			
			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				if(checkedId == femaleButton.getId()){
					System.out.println("female!");
					Toast.makeText(MainActivity.this, "female",Toast.LENGTH_SHORT).show();
				}
				else if(checkedId == maleButton.getId()){
					System.out.println("male!");
				}
			}
		});
        
        checkSwim.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
			
			@Override
			public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
				if(isChecked){
					System.out.println("Swim is Checked!");
				}
				else{
					System.out.println("Swim not Checked!");
				}
			}
		});
        
        checkRun.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){

			@Override
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				if(isChecked){
					System.out.println("Run is Checked!");
				}
				else{
					System.out.println("Run not Checked!");
				}
			}
        	
        });
        
        checkRead.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
			
			@Override
			public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
				if(isChecked){
					System.out.println("Read is Checked!");
				}
				else{
					System.out.println("Read not Checked!");
				}
			}
		});
    }
    
}
